package com.example.charlotte.snakegame;

import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;

public class Block {
    private int x;
    private int y;
    private int dir;

    public static final int LEFT = 0;
    public static final int RIGHT = 1;
    public static final int UP = 2;
    public static final int DOWN = 3;
    public static final int WIDTH = 20;


    public Block(int x, int y, int dir) {
        this.x = x;
        this.y = y;
        this.dir = dir;
    }

    public int getX() {
        return x;
    }

    public void setX(int x) {
        this.x = x;
    }

    public int getY() {
        return y;
    }

    public void setY(int y) {
        this.y = y;
    }

    public int getDir() {
        return dir;
    }

    public void setDir(int dir) {
        this.dir = dir;
    }

    public void logic() {
        switch (dir) {
            case LEFT:
                x -= WIDTH;
                break;
            case RIGHT:
                x += WIDTH;
                break;
            case UP:
                y -= WIDTH;
                break;
            case DOWN:
                y += WIDTH;
                break;

        }
    }
    public void drawHead(Canvas canvas, Paint paint){
        paint.setColor(Color.DKGRAY);
        canvas.drawRect(x,y,x+WIDTH,y+WIDTH,paint);
        paint.setColor(Color.WHITE);
        canvas.drawCircle(x+10,y+10,4,paint);
    }
        public void drawBody(Canvas canvas, Paint paint,String color1,String color2){
        paint.setColor(Color.parseColor(color1));
        canvas.drawRect(x,y,x+WIDTH,y+WIDTH,paint);
         paint.setColor(Color.parseColor(color2));
        canvas.drawRect(x,y,x+WIDTH-5,y+WIDTH-5,paint);
    }

}
